<?php
require_once('lib/event.php');
$is_admin = $_SESSION['status_code'] == 'ADMIN';
?>
<script src="pages_admin/club/_club.js" type="text/javascript"></script>
<h3>Événements, sorties et compétitions</h3>
<?php echo $is_admin ? '<p class="add"><a href="?p=club&amp;r=events_edit">Ajouter un nouvel événement</a></p>' : ''; ?>
<?php
$events = event_get_list();
if ($row = mysql_fetch_assoc($events)) {
	?>
	<table class="dataTable">
		<thead>
		<tr>
			<th>Nom</th>
			<th>Type</th>
			<th>Date</th>
			<th>Date<br />Création</th>
			<th>Nombre de<br />participants</th>
			<th>Action</th>
		</tr>
		</thead>
		<tbody>
	<?php
	do {
		echo '
		<tr>
			<td>'.$row['name'].'</td>
			<td>'.event_type_name($row['type']).'</td>
			<td>'.date_to_str($row['time_event']).'</td>
			<td>'.date_to_str($row['time_create']).'</td>
			<td class="numeric">'.$row['count_join'].'</td>
			<td>
				<a href="?p=club&amp;r=events_members&amp;id='.$row['id'].'" title="Consulter">
					<img src="images/icons/magnifier.png" alt="view" />
				</a>';
				if($is_admin)
				echo '
				<a href="?p=club&amp;r=events_edit&amp;id='.$row['id'].'" title="Modifier">
					<img src="images/icons/pencil.png" alt="edit" />
				</a>
				<a href="?p=club&amp;r=events_add_member&amp;id='.$row['id'].'" title="Forcer l\'ajout d\'un membre">
					<img src="images/icons/user_add.png" alt="add-member" />
				</a>
				<span>
					<a href="javascript:void(0);" class="js-ask-validation" title="Supprimer cet événement">
						<img src="images/icons/delete.png" alt="supprimer" />
					</a>
					<div class="hidden decalhaut">
						Supprimer définitivement ?<br />
						<a href="javascript:void(0);" class="js-del-event b-oui" id="event_'.$row['id'].'"></a>
						<a href="javascript:void(0);" class="js-hide b-non"></a>
					</div>
				</span>';

				echo '
			</td>
		</tr>
		';
	} while ($row = mysql_fetch_assoc($events));
	?>
		</tbody>
	</table>
	<?php
}
else {
	?>
	<p class="info">Il n'y a aucun événement pour le moment</p>
	<?php
}
